package com.mzj.saas.jobs.bill.repository;

import com.mzj.saas.jobs.bill.entity.EstateExpenseBill;
import com.mzj.saas.jobs.bill.entity.EstateRentBill;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import javax.persistence.OrderBy;
import java.util.List;

public interface EstateRentBillRepository extends PagingAndSortingRepository<EstateRentBill, Long>, JpaSpecificationExecutor<EstateRentBill>, JpaRepository<EstateRentBill, Long> {
	List<EstateRentBill> findByIdIn(List<Long> ids);

	@OrderBy("create_time  asc")
	List<EstateRentBill> findByAuditStatusAndPaymentStatus(Integer auditStatus,Integer paymentStatus);

	@Query("select ee from EstateRentBill ee where ee.auditStatus = ?1 and  ee.paymentStatus in (?2,2) and  ee.houseId = ?3 order by ee.createTime asc")
	List<EstateRentBill> findByAuditStatusAndPaymentStatusAndHouseId(Integer auditStatus, Integer paymentStatus, String houseId);

	@Query("select ee from EstateRentBill ee where ee.auditStatus = ?1 and  ee.paymentStatus in (?2,2)  and  ee.houseId = ?3 and ee.orgId = ?4 order by ee.createTime asc")
	List<EstateRentBill> findByAuditStatusAndPaymentStatusAndHouseIdAndOrgId(Integer auditStatus, Integer paymentStatus, String houseId,Long orgId);

	@Query("select ee from EstateRentBill ee where ee.auditStatus = ?1 and  ee.paymentStatus in (?2,?3) ")
	List<EstateRentBill> findByAuditStatusAndPaymentStatus(Integer auditStatus, Integer paymentStatus, Integer paymentStatus1);

}
